#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cmath> 
#include<cstdio>
#include<vector> 
#include<stack>
#include<queue>
#include<algorithm>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PII pair<int,int>
#define inf 0x3f3f3f3f
#define endl "\n"
typedef long long ll;
using namespace std;
int t,n,m,k;
string s;1
const int maxn = 1e5+5;
int a[10],vis[10]; 
ll ans;
bool check(ll x)
{
    memset(vis,0,sizeof vis);
    while(x){
        vis[x % 10]++;
        x /= 10;
    }
    for(int i = 1 ; i <= 9 ; i++){
        if(vis[i] != 1) return false;
    }
    return true;
}
void solve()
{
    for(int i = 1 ; i <= 9 ; i++) a[i] = i;
    do{
        for(int i = 1 ; i <= 8 ; i++){
            ll x = 0;
            for(int j = 1 ; j <= i ; j++){
                x = x * 10 + a[j];
                ll y = 0;
                for(int k = i + 1 ; k <= 9 ;k++){
                    y = y * 10 + a[k];
                    if(check(x * y)){
                        ans = max(ans,x*y);
                    }
                }
            }
        
        }
        
    }while(next_permutation(a+1,a+10));
    cout << ans << endl;
}
int main() {
    IOS;                           
    solve();     
    return 0; 
}

